<template>
  <div>
    <el-container>
      <el-card class="box-card">
        <el-form v-model="userForm">
          <el-form-item label-width="200" label="用户名">
            <el-input v-model="userForm.username"></el-input>
          </el-form-item>
          <el-form-item label-width="200" label="密码">
            <el-input v-model="userForm.password"></el-input>
          </el-form-item>
          <el-form-item>
              <el-button @click="login">登录</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'LoginView',
  data () {
    return {
      userForm: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    login () {
      this.axios.post('/myprocesslogin?username=' + this.userForm.username + '&password=' + this.userForm.password)
        .then(res => {
          if (res.data.code === 200) {
            this.$message.success('登录成功')
            this.$store.commit('setLoginUser', res.data.jdata)
            this.$store.commit('setLoginTime')
            this.$router.push('/account')
          } else {
            this.$message.error('登录失败')
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
